﻿
namespace Mulala.Cavan.Presentation.Seedwork
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.Contracts;
    using System.Linq;
    using Mulala.Cavan.Core.Persistent;
    /// <summary>
    ///     EntityController (or other custome one) uses this interface to 
    ///     Store and ReStore data among many requests
    /// </summary>
    public interface IStateObject
    {
        /// <summary>
        ///     Currently edited item which is kept in session until persisted. 
        ///     It should be used only during the Add or Edit action.
        ///     In other cases this should be set to null (to lower session size)
        /// </summary>
        IPersistentObject Item { get; set; }

        /// <summary>
        ///     The core implementation of the EntityController 
        ///     Stores and Restores searching parameters in/from session
        ///     to keep the latest user's filter settings.
        ///     Application can therefore provide rich UI elemnts even without viewstate.
        /// </summary>
        ISearch SearchParam { get; set; }

        /// <summary>
        ///     keeps the SearchParam used for "SearchFor" actions.
        /// </summary>
        ISearch SearchForParam { get; set; }

        /// <summary>
        ///     The Item of currently edited Item (EntityController)
        /// </summary>
        string ItemID { get; set; }

        /// <summary>
        ///     Container for any other data to be stored and restored for the 'Controller-User' purposes
        /// </summary>
        IDictionary<string, object> OtherElements { get; set; }
    }
}